package com.code.user.client;

import com.code.commons.constants.ServerConstants;
import com.code.commons.service.RestfulCrudService;
import com.code.user.client.hystrix.LoginCredentialClientHystrix;
import com.code.user.model.po.LoginCredential;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 暴露的用户登录验证相关的restful风格的api
 *
 * @author tangyifei
 * @since 2019-5-24 09:28:58
 */
@FeignClient(value = ServerConstants.USER, path = "login-credentials", fallback = LoginCredentialClientHystrix.class)
public interface LoginCredentialClient extends RestfulCrudService<LoginCredential, Long> {

    /**
     * 获取单个登录凭证相关的信息
     *
     * @param account 账号
     * @param type    类型
     * @return 登录凭证
     */
    @GetMapping("_by-account-type")
    LoginCredential getLoginCredential(@RequestParam("account") String account, @RequestParam("type") String type);

    /**
     * 获取多个登录凭证信息列表
     *
     * @param account 账号
     * @param type    类型
     * @return 登录凭证信息列表
     */
    @GetMapping("_by-account-types")
    List<LoginCredential> getLoginCredentialList(@RequestParam("account") String account, @RequestParam("type") List<String> type);

    /**
     * 重置交易密码
     *
     * @param id         凭证主键
     * @param newTranPwd 用户新交易密码
     */
    @PatchMapping("/modify-tran-pwd")
    void modifyTranPwd(@RequestParam("id") Long id, @RequestParam("newTranPwd") String newTranPwd);

    /**
     * 通过用户主键获取用户登录凭证信息
     *
     * @param userId 用户主键
     * @return 用户登录凭证信息
     */
    @GetMapping("/get-login-credential")
    LoginCredential getUserLoginCredential(@RequestParam("userId") String userId);

}
